import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';

@Component({
  selector: 'app-top',
  templateUrl: './top.component.html',
  styleUrls: ['./top.component.css']
})
export class TopComponent implements OnInit {
  uname: string;
  constructor(
    private router: Router
  ) { }

  ngOnInit() {
    const userInfo = localStorage.getItem('userInfo');
    console.log(userInfo);
   if (userInfo) {
     this.uname = JSON.parse(userInfo).perName;
   }
  }
  loginOut() {
    localStorage.removeItem('userInfo');
    this.router.navigate(['proLogin']);
  }

}
